@extends('backend.layouts.app')

@section('title', $title = '网站管理')

@section('breadcrumb')
    <a href="">系统设置</a>
    <a href="">集成系统</a>
    <a href="">{{$title}}</a>
@endsection

@section('content')
    <div class="layui-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>{{$title}}</legend>
        </fieldset>

        <div class="layui-btn-group demoTable">
            <a href="{{ route('site.create') }}" class="layui-btn">添加</a>
            @if(\Auth::user()->type==0)
                <button class="layui-btn  layui-btn-danger" data-type="getCheckData"><i class="layui-icon"></i> 删除
                </button>
            @endif
        </div>

        <div class="layui-form">
            @if($sites->count())
                <table class="layui-table" lay-data="{id:'DeleteTable'}">
                    <thead>
                    <tr>
                        <th lay-data="{type:'checkbox'}">#</th>
                        <th lay-data="{field:'id', width:50, sort: true}">#</th>
                        <th lay-data="{field:'money', width:120, sort: true}">网站余额</th>
                        <th lay-data="{field:'site_name',  sort: true}">网站显示名</th>
                        <th lay-data="{field:'username',  sort: true}">网站名</th>
                        <th lay-data="{field:'agent',  sort: true}">网站代理</th>
                        <th lay-data="{field:'name',  sort: true}">后台账户</th>
                        <th lay-data="{field:'is_external', width:140, sort: true}">外部网站</th>
                        <th lay-data="{field:'status', width:100, sort: true}">可用</th>
                        <th lay-data="{field:'gj',  sort: true}">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($sites as $index => $site)
                        <tr>
                            <td></td>
                            <td>{{ $site->id }}</td>
                            <td>{{ $site->money  }}</td>
                            <td>{{ $site->site_name  }}</td>
                            <td>{{ $site->username  }}</td>
                            <td>{{ $site->agent->name??''  }}</td>
                            <td>{{ $site->user->name??''  }}</td>
                            <td>{{ $site->is_external?'是':'否'  }}</td>
                            <td>{{ $site->status?'是':'否'  }}</td>
                            <td>
                                <a href="{{ route('site.show', $site->id) }}"
                                   class="layui-btn layui-btn-sm layui-btn-normal">查看</a>
                                <a href="{{ route('site.edit', $site->id) }}"
                                   class="layui-btn layui-btn-sm layui-btn-normal">编辑</a>
                                @if(\Auth::user()->type==0)
                                    <a href="{{ route('site.admin_deposit', $site->id) }}"
                                       class="layui-btn layui-btn-sm">充值</a>
                                    <a href="javascript:;" data-url="{{ route('site.destroy', $site->id) }}"
                                       class="layui-btn layui-btn-sm layui-btn-danger form-delete">删除</a>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                <form id="delete-form" action="" method="POST" style="display:none;">
                    <input type="hidden" name="_method" value="DELETE">
                    {{ csrf_field() }}
                </form>
                <div id="paginate-render"></div>
            @else
                <br/>
                <blockquote class="layui-elem-quote">暂无数据!</blockquote>
            @endif

        </div>
    </div>

@endsection

@section('scripts')
    @include('backend.layouts._paginate',[ 'count' => $sites->total(), 'delBatchUrl'=>route('site.batch_destroy'),'limit'=>config('administrator.paginate.limit')])
@endsection
